#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : gtmsAutoTestProject 
@File    : overseas_upload_daily_data_interface.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/9/27 12:00 
@Describe:
"""
from fastapi import APIRouter
from Comm.logUtils.logControl import LogHandler
from FastApi.dto.pos.order.overseas_upload_daily_data_dto import OverseasUploadDailyDataDtoModel
from FastApi.server.pos.order.overseas_upload_daily_data_server import OverseasUploadDailyDataServer

logger = LogHandler().get_logger()
getOverseasUploadDailyData_route = APIRouter()


@getOverseasUploadDailyData_route.post("/get-upload-daily-data", name="获取海外物业每日上传数据")
async def getOverseasUploadDailyData(payload: OverseasUploadDailyDataDtoModel):
    logger.info('请求参数:[{}]'.format(payload))
    overseas_server = OverseasUploadDailyDataServer(payload.brandCode, payload.environment)
    result_info = {"code": 200, "message": "请求成功~", "data": []}
    if payload.business_type == 0:
        result_info["data"].append(overseas_server.turnover_data_cleaning(payload.start_time, payload.end_time))
        logger.info('接口响应:[{}]'.format(result_info))
        return result_info
    elif payload.business_type == 1:
        result_info["data"].append(overseas_server.payment_data_cleaning(payload.start_time, payload.end_time))
        logger.info('接口响应:[{}]'.format(result_info))
        return result_info
    else:
        result_info = {"code": 5000, "message": "请输入正确的请求参数!"}
        logger.warning('接口响应:[{}]'.format(result_info))
        return result_info
